package com.mab.apipassenger.service;

import com.mab.apipassenger.remote.ServicePassengerUserClient;
import com.msb.internalcommon.dto.PassengerUser;
import com.msb.internalcommon.dto.ResponseResult;
import com.msb.internalcommon.dto.TokenResult;
import com.msb.internalcommon.request.VerificationCodeDTO;
import com.msb.internalcommon.util.JwtUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Auther: jiudianliu
 * @Date: 2023/5/26 - 05 - 26 - 17:51
 * @Description: com.mab.apipassenger.service
 * @version: 1.0
 */
@Service
@Slf4j
public class UserService {

    @Autowired
    ServicePassengerUserClient servicePassengerUserClient ;

    public ResponseResult getUserByAccessToken(String accessToken){

        log.info("accessToken:" + accessToken);
        //解析accessToken  拿到手机号
        TokenResult tokenResult = JwtUtils.checkToken(accessToken);
        String phone = tokenResult.getPhone();
        //根据手机号查询用户信息
        ResponseResult<PassengerUser> userByPhone = servicePassengerUserClient.getUserByPhone(phone);
        return ResponseResult.success(userByPhone.getData()) ;
    }
}
